from api.IhrmEmployeesApi import IhrmEmployeeApi
from common.assert_tools import assert_tools


#定义测试类
class TestIhrmEmpAdd(object):
    #添加员工成功--必填参数
    def test01_add_ok(self):
        headers_data={"Content-Type":"application/json",
                      "Authorization":"Bearer dbf739f9-0dd2-4237-aab3-45da18f39c6d"}
        json_data={"username":"AAAaaa","mobile":"18845612580","workNumber":"0007"}
        resp=IhrmEmployeeApi.add_emp(headers_data,json_data)
        print("必填，添加成功：",resp.json())
        assert_tools(resp,200,True,10000,"操作成功")
    #添加成功--全部参数
    def test02_add_ok(self):
        headers_data={"Content-Type":"application/json",
                      "Authorization":"Bearer dbf739f9-0dd2-4237-aab3-45da18f39c6d"}
        json_data={"username":"DDDA","mobile":"18465615690","workNumber":"0001",
                   "timeOfEntry":None,"formOfEmployment":1}
        resp=IhrmEmployeeApi.add_emp(headers_data,json_data)
        print("全部参数，添加成功：",resp.json())
        assert_tools(resp,200,True,10000,"操作成功")
    #添加失败--手机号为空
    def test03_add_error(self):
        headers_data={"Content-Type":"application/json",
                      "Authorization":"Bearer dbf739f9-0dd2-4237-aab3-45da18f39c6d"}
        json_data={"username":"DDDA","mobile":None,"workNumber":"0001"}
        resp=IhrmEmployeeApi.add_emp(headers_data,json_data)
        print("手机号为空，添加失败：",resp.json())
        assert_tools(resp,200,False,99999,"抱歉")